familypediawikiaorg-20200214-history
Help:Semantic MediaWiki/Tips and tricks
Tips The following (partly written by User:Phlox) was on the Help Wikia until bypassed in September 2010: This is a compilation of some SMW and Semantic forms tips and tricks learned by Wikia contributors. Introductory tips *The type "Page" may appear useless because values returned from queries cannot be manipulated in templates because they have square brackets around them. To get the plain text values, add the operand "|link=none " to the query. Advanced tips Values returned from #Ask queries can have hidden text :Problem you will see: #ifeq or #eval and other wikitext functions behave in unexpected ways with results from #ask or #show expressions. For instance, if you display the value returned from #ask, you see "foo", yet expressions like return false. :Verify you have this problem. Do a #len on the string. If this phenomenon is the culprit, you will see a wildly higher number than expected. Instead of the expected "3" for foo, you will see something like 24. :Explanation: SMW is inserting hidden text into the returned values. This may be stripped by a #replace operation. :Fix: |SMW::on|}} The same parameter is repeated in every template fed by a semantic form :Problem you will see: A semantic form with more than one "for template" is used to add data to an article. After editing the article modified by the form, there will be newly inserted parameter values inserted for all templates mentioned in the form. :Explanation: This is caused by mismatching between the form and the templates. By searching on the parameter value in the form and in the templates, you will either see that the there are no templates recieving the parameter, or that one of the templates is expecting a value that has not been set on the form. :Fix: Correct the mismatch by either adding or subtracting the parameters from either the form or templates, so that they are in agreement. Parameters may be passed to template handlers for queries For instance the following syntax will pass the value bar to Template "birthDisplay"'s parameter foo: : foo=bar|?birth locality}} Type:code properties make wide window Properties of type code can be used to store wikitext, however if the facts box is not hidden, these fields can create unusually wide windows forcing the browser to put up a horizontal scroll bar. :Fix: To Mediawiki:monaco.css add the following: /* Set SMW type Code property windows in the SMW factbox so that it doesn't extend past the window size. Also set word wrap for browsers that recognize it (IE, and soon firefox) - Phlox */ .smwpre { width:800px; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word; } Comma delimiter in multi valued property Background: You have a property of type page that holds multiple values. In a query, your #ask sends the output to a template. For the multi valued property, you can parse each value out fine with arraymap using the comma as a delimiter. However, when pages are stored in the multivalued property that themselves have a comma in them (eg. Greene county, Ohio), then the arraymap messes up. :Fix: Do a #replace on ]], with ]]; For example: }|]],|]];}} |;|blah blah blah Replace semicolon with whatever other safe delimiter you want.